import request from '@/utils/request'

/**
 * 获取list数据
 */
export function pageList(restPath, params) {
	const URL = '/api/' + restPath + '/pageList'
	return request({
		url: URL,
		method: 'get',
		params
	})
}

/**
 * 根据ID, 获取数据
 */
export function getObj(restPath, id) {
	const URL = '/api/' + restPath + '/' + id
	return request({
		url: URL,
		method: 'get'
	})
}

/**
 * 添加
 */
export function addObj(restPath, obj) {
	const URL = '/api/' + restPath
	return request({
		url: URL,
		method: 'post',
		data: obj
	});
}

/**
 * 修改
 */
export function putObj(restPath, obj) {
	const URL = '/api/' + restPath
	return request({
		url: URL,
		method: 'put',
		data: obj
	})
}

/**
 * 根据ID, 删除数据
 */
export function deleteObj(restPath, id) {
	const URL = '/api/' + restPath + '/' + id
	return request({
		url: URL,
		method: 'delete'
	})
}

/**
 * 删除文件
 */
export function deleteFile(restPath, obj) {
  const URL = '/api/' + restPath + '/deleteFile'
	return request({
    url: URL,
    method: 'post',
    data: obj
	})
}

/**
 * 根据图片路径, 删除图片
 */
export function deleteImage(data) {
  const URL = '/api/file/deleteImage'
  return request({
    url: URL,
    method: 'post',
    data
  })
}

/**
 * 根据dictIds,获取数据字典
 */
export function getDictData(params) {
  const URL = '/api/sys/dict/getDictData'
  return request({
    url: URL,
    method: 'get',
    params
  })
}
